#include <cstdio>

int main( )
{
    int n, i, j, k;
    __int64 m, t1, t2;
    bool space, use[ 21 ];
    while ( scanf("%d%I64d", &n, &m) != EOF )
    {
        space = false;
        t1 = 1;
        t2 = n - 1;
        for ( i = 1; i < n; i++ )
        {
            t1 += t2;
            t2 *= n - i - 1;
        }
        for ( i = 1; i <= n; i++ )
            use[ i ] = false;
        t2 = 1;
        for ( i = 1; i <= n - 1; i++ )
            t2 *= i;
        i = 1;
        while ( m && m != -1 )
        {
            if ( m >= t1 )
            {
                if ( space )
                    printf(" ");
                else
                    space = true;
                t2 = m / t1 + ( m % t1 != 0 );
                j = 0;
                for ( k = 1; j != t2; k++ )
                    if ( !use[ k ] )
                        j++;
                printf("%d", k - 1);
                use[ k - 1 ] = true;
                m = m - ( m / t1 - ( m % t1 == 0 ) ) * t1 - 1;
            }
            else
            {
                if ( space )
                    printf(" ");
                else
                    space = true;
                for ( k = 1; k <= n; k++ )
                    if ( !use[ k ] )
                    {
                        printf("%d", k);
                        use[ k ] = true;
                        break;
                    }
                m--;
            }
            t1 = 1;
            t2 = n - 1 - i;
            for ( j = 1; j <= n - 1 - i; j++ )
            {
                t1 += t2;
                t2 *= n - j - 1 - i;
            }
            i++;
        }
        printf("\n");
    }
    return 0;
}
